package edu.nju;

import java.io.*;

/**
 * format : dir/subdir;dir/subdir/*;dir/target.jar*
 */
public class CompositeEntry extends Entry{
    public CompositeEntry(String classpath) {
        super(classpath);
    }

    @Override
    public byte[] readClassFile(String className) throws IOException {
    	String[] temp=classpath.split(File.pathSeparator);
    	for (int i=0;i<temp.length;i++) {
    		if (temp[i].contains(".")) {
    			Entry shit=new ArchivedEntry(temp[i]);
    			if (shit.readClassFile(className)!=null)
    				return shit.readClassFile(className);
    			continue;
    		}
    		if (temp[i].endsWith("*")) {
    			Entry shit=new WildEntry(temp[i]);
    			if (shit.readClassFile(className)!=null)
    				return shit.readClassFile(className);
    			continue;
    		}
			Entry shit=new DirEntry(temp[i]);
			if (shit.readClassFile(className)!=null)
				return shit.readClassFile(className);
    	}
        return null;
    }
}
